fix(ci): use portable fallbacks for bash-4 builtins and GNU sed in hook scripts - #3694
fix(ci): use portable fallbacks for bash-4 builtins and GNU sed in hook scripts#3694jiengup wants to merge 1 commit into
Conversation
|
Thanks for the PR. It is labeled Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
hubcio
left a comment
There was a problem hiding this comment.
the -i.bak switch itself is the right call and matches the trailing-whitespace.sh precedent. main ask is the && rm -f chaining - it quietly replaces the old loud sed failure with a false "Fixed" + exit 0 (details in the line comments).
two findings sit on lines outside this diff, so noting them here:
scripts/verify-crates-publish.sh:313-lc="${crate,,}"is bash-4-only, stock macOS bash 3.2 dies withbad substitution, and it fails late (after all four crates already published to the local registry). it's also a no-op since the crate names are already lowercase, solc="$crate"fixes it for free.scripts/ci/python-sdk-version-sync.sh:144-sort -Vis GNU coreutils-only, BSD sort rejects it. the--fixpath hits it exactly when the two versions differ, i.e. the case the hook exists for. worth confirming on an actual mac.
with a\, \b and these two still around, #3693 ends up only partially closed for macos contributors - either keep the issue open or note a follow-up in the PR.
Appreciate your detailed review. Problems fixed in the newest patch:
Additional change:
Leave as a follow-up issue:
|
|
/ready |
ethanlin01x
left a comment
There was a problem hiding this comment.
Left a few minor comments inline. I ran into this problem myself on macOS, so I'd love to see this merged soon — thanks for the fix!
| # Compare base versions using POSIX sort (X.Y.Z numeric per component). | ||
| local sorted | ||
| sorted=$(printf '%s\n%s' "$base1" "$base2" | sort -V | head -1) | ||
| sorted=$(printf '%s\n%s' "$base1" "$base2" | sort -t. -k1,1n -k2,2n -k3,3n | head -1) |
There was a problem hiding this comment.
sort -V works fine on stock macOS (verified locally). Since the original way isn't broken and numeric keys only fit pure numbers, let's revert to -V. consider reverting to -V.
| awk -v major="$PYTHON_VERSION_MAJOR" -v version="$PYTHON_VERSION" ' | ||
| { print } | ||
| $0 == " \"Programming Language :: Python :: " major "\"," { | ||
| printf " \"Programming Language :: Python :: %s\",\n", version | ||
| } | ||
| ' "$file" > "$file.new" && mv "$file.new" "$file" |
There was a problem hiding this comment.
Could you split the awk and mv into two statements? With &&, a failed awk is exempt from set -e, so the script would still print "Fixed" and exit 0 with the file unedited — same errexit swallow as the earlier sed -i.bak ... && rm sites.
Closes #3693
Rationale
Several hook scripts use
mapfile(bash >= 4) andsed -iwithout backup extension (GNU extension). On macOS stock bash 3.2 and BSD sed, these fail, blocking contributors from committing.What changed
mapfilecalls now guard withcommand -v mapfileand fall back to awhile IFS= read -rloop.sed -icalls is replaced by thesed -i.bak && rmpattern already established intrailing-whitespace.sh.Local Execution
prek run -a